const formatTime = timestamp => {
  let date = new Date(timestamp);
  const year = date.getFullYear();
  const month = date.getMonth() + 1;
  const day = date.getDate();
  const hour = date.getHours();
  const minute = date.getMinutes();
  const second = date.getSeconds();

  return [year, month, day].map(formatNumber).join('-') + ' ' + [hour, minute, second].map(formatNumber).join(':');
}

const formatTimeChinese = timestamp => {
  let date = new Date(timestamp);
  const year = formatNumber(date.getFullYear()) + '年';
  const month = formatNumber(date.getMonth() + 1) + '月';
  const day = formatNumber(date.getDate()) + '日';

  return year + month + day;
}

const formatNumber = n => {
  n = n.toString();
  return n[1] ? n : '0' + n;
}

//检测手机号格式
const checkMobilePhoneNumber = value => {
  let reg = /^1\d{10}$/;
  if ((reg.test(value))) {
    return true;
  }
  return false;
}
http: //pemfoff8h.bkt.clouddn.com/Fud4O0Dfl-ypH8rdAXN8If2OEgP0
  //检测密码格式
  const checkPassword = value => {
    let reg = /^[a-zA-Z0-9]{6,16}$/;
    if ((reg.test(value))) {
      return true;
    }
    return false;
  }

module.exports = {
  formatTime: formatTime,
  formatTimeChinese: formatTimeChinese,
  checkMobilePhoneNumber: checkMobilePhoneNumber,
  checkPassword: checkPassword,
}